package metalink.admin;

import java.util.ArrayList;

import model.admin.GetCourseListMo;
import model.admin.GetListsMo;
import model.admin.ModifyCoursesMo;
import vo.mixed.CourseListVo;
import vo.mixed.DepartmentListVo;

import com.opensymphony.xwork2.ActionSupport;

public class ModifyCourseList extends ActionSupport {
	int course_id;
	int batch_id;
	int department_id;
	int duration;
	int credit;
	int start_year;
	int year_selected;
	String course_code;
	String course_name;
	String course_selected;
	String description;
	String department_name;
	String status;
	String value;
	ArrayList<String> batch_course_list;
	ArrayList<String> batch_department_list;
	ArrayList<DepartmentListVo> department_list = new ArrayList<DepartmentListVo>();
	ArrayList<CourseListVo> courselist = new ArrayList<CourseListVo>();
	
	public ArrayList<CourseListVo> getCourselist() {
		return courselist;
	}

	public void setCourselist(ArrayList<CourseListVo> courselist) {
		this.courselist = courselist;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public ArrayList<DepartmentListVo> getDepartment_list() {
		return department_list;
	}

	public void setDepartment_list(ArrayList<DepartmentListVo> department_list) {
		this.department_list = department_list;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public int getStaff_id() {
		return staff_id;
	}

	public void setStaff_id(int staff_id) {
		this.staff_id = staff_id;
	}

	ArrayList<Integer> year_list;
	int staff_id;
	int professor_course;
	private int theory;
	private int lab;

	public int getstaff_id() {
		return staff_id;
	}

	public void setstaff_id(int staff_id) {
		this.staff_id = staff_id;
	}

	public int getProfessor_course() {
		return professor_course;
	}

	public void setProfessor_course(int professor_course) {
		this.professor_course = professor_course;
	}

	public int getYear_selected() {
		return year_selected;
	}

	public void setYear_selected(int year_selected) {
		this.year_selected = year_selected;
	}

	public ArrayList<Integer> getYear_list() {
		return year_list;
	}

	public void setYear_list(ArrayList<Integer> year_list) {
		this.year_list = year_list;
	}

	public String getCourse_code() {
		return course_code;
	}

	public void setCourse_code(String course_code) {
		this.course_code = course_code;
	}

	public int getCourse_id() {
		return course_id;
	}

	public void setCourse_id(int course_id) {
		this.course_id = course_id;
	}

	public String getCourse_name() {
		return course_name;
	}

	public void setCourse_name(String course_name) {
		this.course_name = course_name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public int getBatch_id() {
		return batch_id;
	}

	public void setBatch_id(int batch_id) {
		this.batch_id = batch_id;
	}

	public int getDepartment_id() {
		return department_id;
	}

	public void setDepartment_id(int department_id) {
		this.department_id = department_id;
	}

	public String getDepartment_name() {
		return department_name;
	}

	public void setDepartment_name(String department_name) {
		this.department_name = department_name;
	}

	public String getCourse_selected() {
		return course_selected;
	}

	public void setCourse_selected(String course_selected) {
		this.course_selected = course_selected;
	}

	public int getDuration() {
		return duration;
	}

	public int getTheory() {
		return theory;
	}

	public void setTheory(int theory) {
		this.theory = theory;
	}

	public int getLab() {
		return lab;
	}

	public void setLab(int lab) {
		this.lab = lab;
	}

	public void setDuration(int duration) {
		this.duration = duration;
	}

	public int getCredit() {
		return credit;
	}

	public void setCredit(int credit) {
		this.credit = credit;
	}

	public ArrayList<String> getBatch_course_list() {
		return batch_course_list;
	}

	public void setBatch_course_list(ArrayList<String> batch_course_list) {
		this.batch_course_list = batch_course_list;
	}

	public int getStart_year() {
		return start_year;
	}

	public void setStart_year(int start_year) {
		this.start_year = start_year;
	}

	public ArrayList<String> getBatch_department_list() {
		return batch_department_list;
	}

	public void setBatch_department_list(ArrayList<String> batch_department_list) {
		this.batch_department_list = batch_department_list;
	}

	public String execute() {
		GetListsMo list = new GetListsMo();
		ModifyCoursesMo mo= new ModifyCoursesMo();
		GetCourseListMo coursemo = new GetCourseListMo();
		setBatch_course_list(list.getCourseList(batch_id, 0, 0));
		setYear_list(list.GetYearList());
		setDepartment_list(list.getDepartmentList());
		if (value.contentEquals("updatecourse")){
			mo.updateCourseDetails(course_id,course_name,course_code,credit,duration,lab,theory,department_id,start_year,status,value);
			//courselist=coursemo.getCourseList(0);
		}
		//department_list;
		return SUCCESS;
	}
/*
	public String updateCourse() {
		CourseListVo editCourse = new CourseListVo();
		editCourse.setCourse_id(getCourse_id());
		editCourse.setCourse_name(getCourse_name());
		editCourse.setCourse_code(getCourse_code());
		editCourse.setCredit(credit);
		editCourse.setDuration(duration);
		editCourse.setLab(lab);
		editCourse.setTheory(theory);
		editCourse.setDepartment_id(department_id);
		editCourse.setStart_year(start_year);
		editCourse.setStatus(status);
		ModifyCoursesMo obj = new ModifyCoursesMo();
		obj.updateCourseDetails(editCourse);
		System.out.println(getDepartment_id() + " depr id ");
		return SUCCESS;
		// else
		// return ERROR;
	}
*/
	public String addBatchCourse() {
		System.out.println(year_selected + "  selected year " + course_selected
				+ "  Selected course ");
		CourseListVo BatchCourse = new CourseListVo();
		BatchCourse.setCourse_code(course_code);
		BatchCourse.setCourse_name(course_selected);
		BatchCourse.setCredit(credit);
		BatchCourse.setDuration(duration);
		BatchCourse.setStart_year(year_selected);
		System.out.println(year_selected + "  selected year " + course_selected
				+ "  Selected course " + batch_id + "  batch_id ");
		ModifyCoursesMo single_obj = new ModifyCoursesMo();
		single_obj.addCourseDetails(BatchCourse, batch_id,"AddbatchCourse");
		return SUCCESS;
	}

	public String addCourse() {
		CourseListVo newCourse = new CourseListVo();
		newCourse.setCourse_code(course_code);
		newCourse.setCourse_name(course_name);
		newCourse.setCredit(credit);
		newCourse.setDuration(duration);
		newCourse.setDepartment_name(department_name);
		newCourse.setDepartment_id(department_id);
		ModifyCoursesMo courseModel = new ModifyCoursesMo();
		courseModel.addCourseDetails(newCourse, batch_id,"AddCourse");
		return SUCCESS;

	}

	public String courseAdd(){
		GetListsMo list = new GetListsMo();
		setDepartment_list(list.getDepartmentList());
		return SUCCESS;
	}
	public String deleteCourseDetails() {

		ModifyCoursesMo m = new ModifyCoursesMo();
		m.deleteCourseDetails(course_id,"DeleteCourse");
		return SUCCESS;

	}

	public String deleteCourseProfessor() {
		ModifyCoursesMo m = new ModifyCoursesMo();
		System.out.println(staff_id);
		m.deleteCourseProfessor(course_id, staff_id,"DeleteCourseprofessor");

		return SUCCESS;
	}

	public String CourseProfessorCourseDetails() {
		ModifyCoursesMo m = new ModifyCoursesMo();
		System.out.println(staff_id);
		m.deleteCourseProfessor(course_id, staff_id,"DeleteCourseprofessorCourse");
		return SUCCESS;
	}

	public String addNewCourseSubmit()
	{
		CourseListVo newCourse = new CourseListVo();
		newCourse.setCourse_code(course_code);
		newCourse.setCourse_name(course_name);
		newCourse.setCredit(credit);
		newCourse.setDuration(duration);
		newCourse.setLab(lab);
		newCourse.setTheory(theory);
		newCourse.setStart_year(start_year);
		newCourse.setDepartment_id(department_id);
		ModifyCoursesMo courseModel = new ModifyCoursesMo();
		courseModel.addCourseDetails(newCourse, 0,"AddCourseDetail");
		return SUCCESS;		
	}
}
